feat(backend): make memory cache sweep interval configurable and clearable (#643)#728
Merged
ogazboiz merged 1 commit intoJun 1, 2026
Conversation
…rable (LabsCrypt#643) - Replace the hardcoded 60s sweep interval with a configurable interval reading process.env.MEMORY_CACHE_SWEEP_MS (defaulting to 60_000ms). - Store the interval handle and export stopMemoryCacheSweep() to prevent leaking timers across Vitest runs. - Call stopMemoryCacheSweep() in disconnectRedis() for symmetry. - Document MEMORY_CACHE_SWEEP_MS in .env.example. - Expose startMemoryCacheSweep() and stopMemoryCacheSweep() in unit tests to test configuration and cleanup.
ogazboiz
approved these changes
Jun 1, 2026
Contributor
ogazboiz
left a comment
There was a problem hiding this comment.
clean — closes #643 (cache sweep interval now AUTH_CHALLENGE_SWEEP_INTERVAL_MS-style configurable + clearable in tests). all CI green. merging!
join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #643.
Description
60_000msMemoryCache cleanup sweep interval inbackend/src/lib/redis.tswith a configurable interval that reads fromprocess.env.MEMORY_CACHE_SWEEP_MS(defaulting to60_000ms).stopMemoryCacheSweep()to clean it up and prevent active timer leaks.startMemoryCacheSweep(intervalMs?: number)to allow manual control or testing of different interval values.stopMemoryCacheSweep()insidedisconnectRedis()for symmetry.MEMORY_CACHE_SWEEP_MSwith its default value inbackend/.env.example.backend/tests/redis.test.tsto test cache sweep behavior (start, stop, and custom intervals), using a teardown block to prevent state leakage.